// -----------------------------------------------------------------------------------------
// Table of Content for Blogger with Pagination
// Original: http://vagabundia.blogspot.com/2011/04/resumen-de-entradas-con-paginacion.html
// Modified by Taufik Nurrohman http://www.dte.web.id
// http://info-kmu.blogspot.com/
// -----------------------------------------------------------------------------------------

function showpageposts(e) {
    var t, n, r, i;
    var s = "";
    if (pagernum == 0) {
        postsnum = parseInt(e["feed"]["openSearch$totalResults"].$t);
        pagernum = parseInt(postsnum / postsperpage) + 1
    }
    for (var o = 1; o < postsperpage; o++) {
        if (o == e["feed"]["entry"]["length"]) {
            break
        }
        t = e["feed"]["entry"][o];
        n = t["title"]["$t"];
        for (var u = 0; u < t["link"]["length"]; u++) {
            if (t["link"][u]["rel"] == "alternate") {
                r = t["link"][u]["href"];
                break
            }
        }
        for (var a = 0; a < t["link"]["length"]; a++) {
            if (t["link"][a]["rel"] == "replies" && t["link"][a]["type"] == "text/html") {
                var f = t["link"][a]["title"]["split"](" ")[0];
                break
            }
        }
        if ("content" in t) {
            var l = t["content"]["$t"]
        } else {
            if ("summary" in t) {
                var l = t["summary"]["$t"]
            } else {
                var l = ""
            }
        }
        var c = /<\S[^>]*>/g;
        l = l["replace"](c, "");
        if (l["length"] > numchars) {
            l = l["substring"](0, numchars) + "..."
        }
        var h = t["published"]["$t"],
            p = h["substring"](0, 4),
            d = h["substring"](5, 7),
            v = h["substring"](8, 10);
        var m = new Array;
        if (idMode) {
            m[1] = "Jan";
            m[2] = "Feb";
            m[3] = "Mar";
            m[4] = "Apr";
            m[5] = "Mei";
            m[6] = "Jun";
            m[7] = "Jul";
            m[8] = "Agt";
            m[9] = "Sep";
            m[10] = "Okt";
            m[11] = "Nov";
            m[12] = "Des"
        } else {
            m[1] = "Jan";
            m[2] = "Feb";
            m[3] = "Mar";
            m[4] = "Apr";
            m[5] = "May";
            m[6] = "Jun";
            m[7] = "Jul";
            m[8] = "Aug";
            m[9] = "Sep";
            m[10] = "Oct";
            m[11] = "Nov";
            m[12] = "Dec"
        }
        var g = showPostDate ? v + " " + m[parseInt(d, 10)] + " " + p + " - " : "";
        var y = showComments ? f + " " + commentsLabel : "";
        if ("media$thumbnail" in t) {
            i = t["media$thumbnail"]["url"]
        } else {
            i = imgBlank
        }
        s += '<div class="you_item">';
        s += '<h6><a title="' + n + '" href="' + r + '">' + n + "</a></h6>";
        s += '<div class="iteminside"><a title="' + n + '" href="' + r + '"><img alt="' + n + '" src="' + i + '" /></a>';
        s += l + "</div>";
        s += '<div style="clear:both;"></div><div class="you_foot">' + g + y + '<a class="itemrmore" href="' + r + '">' + rmoreText + "</a></div>";
        s += "</div>"
    }
    document["getElementById"]("results")["innerHTML"] = s;
    halaman()
}
function halaman() {
    countP = 0;
    output = "";
    if (actualpage > 1) {
        output += '<a class="prevjson" href="javascript:incluirscript(' + parseInt(actualpage - 1) + ')">' + prevText + "</a>"
    } else {
        output += '<span class="prevjson hidden">' + prevText + "</span>"
    }
    if (pagernum < maxpage + 1) {
        for (countP = 1; countP <= pagernum; countP++) {
            if (countP == actualpage) {
                output += '<span class="actual">' + countP + "</span>"
            } else {
                output += '<a href="javascript:incluirscript(' + countP + ')">' + countP + "</a>"
            }
        }
    } else {
        if (pagernum > maxpage - 1) {
            if (actualpage < minpage) {
                for (countP = 1; countP < maxpage - 2; countP++) {
                    if (countP == actualpage) {
                        output += '<span class="actual">' + countP + "</span>"
                    } else {
                        output += '<a href="javascript:incluirscript(' + countP + ')">' + countP + "</a>"
                    }
                }
                output += " ... ";
                output += '<a href="javascript:incluirscript(' + parseInt(pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>";
                output += '<a href="javascript:incluirscript(' + pagernum + ')">' + pagernum + "</a>"
            } else {
                if (pagernum - (minpage - 1) > actualpage && actualpage > minpage - 1) {
                    output += '<a href="javascript:incluirscript(1)">1</a>';
                    output += '<a href="javascript:incluirscript(2)">2</a>';
                    output += " ... ";
                    for (countP = actualpage - 2; countP <= actualpage + 2; countP++) {
                        if (countP == actualpage) {
                            output += '<span class="actual">' + countP + "</span>"
                        } else {
                            output += '<a href="javascript:incluirscript(' + countP + ')">' + countP + "</a>"
                        }
                    }
                    output += " ... ";
                    output += '<a href="javascript:incluirscript(' + parseInt(pagernum - 1) + ')">' + parseInt(pagernum - 1) + "</a>";
                    output += '<a href="javascript:incluirscript(' + pagernum + ')">' + pagernum + "</a>"
                } else {
                    output += '<a href="javascript:incluirscript(1)">1</a>';
                    output += '<a href="javascript:incluirscript(2)">2</a>';
                    output += " ... ";
                    for (countP = pagernum - (minpage + 1); countP <= pagernum; countP++) {
                        if (countP == actualpage) {
                            output += '<span class="actual">' + countP + "</span>"
                        } else {
                            output += '<a href="javascript:incluirscript(' + countP + ')">' + countP + "</a>"
                        }
                    }
                }
            }
        }
    }
    if (actualpage < countP - 1) {
        output += '<a class="nextjson" href="javascript:incluirscript(' + parseInt(actualpage + 1) + ')">' + nextText + "</a>"
    } else {
        output += '<span class="nextjson hidden">' + nextText + "</span>"
    }
    document["getElementById"]("you_hal")["innerHTML"] = output;
    var e = actualpage * postsperpage - (postsperpage - 1);
    var t = actualpage * postsperpage;
    var n = totalPostLabel + " " + postsnum + " - " + jumpPageLabel + " " + e + " - " + t;
    document["getElementById"]("you_tot")["innerHTML"] = n
}
function incluirscript(e) {
    if (firstPage == 1) {
        removerscript()
    }
    document["getElementById"]("results")["innerHTML"] = '<div id="loadingscript">' + loadingText + "</div>";
    document["getElementById"]("you_hal")["innerHTML"] = "";
    document["getElementById"]("you_tot")["innerHTML"] = "";
    var t = e * postsperpage - (postsperpage - 1);
    if (sortByLabel) {
        var n = siteUrl + "/feeds/posts/default/-/" + labelSorter + "?start-index=" + t
    } else {
        var n = siteUrl + "/feeds/posts/default/?start-index=" + t
    }
    n += "&max-results=" + postsperpage;
    n += "&orderby=published&alt=json-in-script&callback=showpageposts";
    var r = document["createElement"]("script");
    r["setAttribute"]("type", "text/javascript");
    r["setAttribute"]("src", n);
    r["setAttribute"]("id", "TEMPORAL");
    document["getElementsByTagName"]("head")[0]["appendChild"](r);
    firstPage = 1;
    actualpage = e
}
function removerscript() {
    var e = document["getElementById"]("TEMPORAL");
    var t = e["parentNode"];
    t["removeChild"](e)
}
var minpage = 4;
var maxpage = 10;
var firstPage = 0;
var pagernum = 0;
var postsnum = 1;
var actualpage = 1;
onload = function () {
    incluirscript(1)
};
document["write"]('<div id="toc-outer">');
document["write"]('<div id="results"></div>');
document["write"]('<div id="itempager" style="position:relative;"><div id="you_hal"></div>');
document["write"]('<div id="you_tot"></div></div></div>')